﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ArithCollect;
using CSharpAlgorithm.Algorithm;
using System.Linq;

namespace UnitTestProject1 {
    /// <summary>
    /// 多项式最小二乘线性回归分析 测试
    /// </summary>
    [TestClass]
    public class LeastSquaresFitTest1 {
        [TestMethod]
        public void TestMethod1() {
            var ss = new [] { 
                Tople.C(2.8,7.5),
                Tople.C(12.8,1.5),
                Tople.C(15d,21d),
                Tople.C(6.8,11.5)
            };
            var xx = ss.MultiCurveEquation(3);
            foreach (var item in xx) {
                Console.WriteLine(item);
            }
            var t = 10.15d;
            var yy = xx.GetMCValue(t);
            Console.WriteLine(xx.ToEquationString());
            Console.WriteLine("yy={0}",yy);
            var x = ss.GetItem().ToArray();
            var y = ss.GetItem(1).ToArray();
            var yy2=Interpolation.GetValueLagrange(ss.Length, x, y, t);
            Console.WriteLine("yy2={0}",yy2);
        }
    }
}
